extends Node2D
class_name Weapon

@export var Bullet:PackedScene


@onready var end_of_gun  = $"发射点"
@onready var gun_direction  = $"发射方向"
@onready var attack_colldown =$AttackCooldown 

@onready var fire_animation_player=$AnimationPlayer

func shoot():
	#为加入场景做准备，注意挂载，信号连接子弹管理器
	if attack_colldown.is_stopped() and Bullet != null:
		var bullet_instance = Bullet.instantiate()
		var target = end_of_gun.global_position
		var direction_to_mouse = gun_direction.global_position.direction_to(target).normalized()
		GlobalSignals.emit_signal("bullet_fired",bullet_instance,end_of_gun.global_position,direction_to_mouse)
		attack_colldown.start()
		fire_animation_player.play("muzzle_flash")
	
